﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//using Microsoft.VisualStudio ;

namespace TimeRegi
{
    public partial class Form_TimeRegistration : Form
    {
        TimeRegistration m_TimeRegistration = new TimeRegistration("SQL2008R2");
        public Form_TimeRegistration()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Application.Idle += new EventHandler(Application_Idle);
        }

        private void Application_Idle(object sender, EventArgs e)
        {
            //it then uses P/Invoke to get access to Windows API message handling routines.

        }

        private static int WM_QUERYENDSESSION = 0x11;
        private static bool systemShutdown = false;

        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            if (m.Msg == WM_QUERYENDSESSION)
            {
                //MessageBox.Show("queryendsession: this is a logoff, shutdown, or reboot");
                m_TimeRegistration.ShutDown ();
                systemShutdown = true;
            }

            // If this is WM_QUERYENDSESSION, the closing event should be
            // raised in the base WndProc.
            base.WndProc(ref m);

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            m_TimeRegistration.ApplicationClosing();
        } //WndProc 


    }
}
